Done this way, it is easily extendable to also handle LUTs.
babl-sampling.c \
babl-sanity.c \
babl-space.c \
+ babl-trc.c \
babl-type.c \
babl-util.c \
babl-cpuaccel.c \
BABL_TYPE_INTEGER,
BABL_TYPE_FLOAT,
BABL_SAMPLING,
+ BABL_TRC,
BABL_COMPONENT,
BABL_MODEL,
BABL_FORMAT,
#include "babl-type.h"
#include "babl-sampling.h"
+#include "babl-trc.h"
#include "babl-space.h"
#include "babl-component.h"
#include "babl-model.h"
BablType type;
BablSampling sampling;
BablSpace space;
+ BablSpace trc;
BablComponent component;
BablModel model;
BablFormat format;
"BablTypeInteger",
"BablTypeFloat",
"BablSampling",
+ "BablTRC",
"BablComponent",
"BablModel",
"BablFormat",
void babl_store_db (void);
int _babl_max_path_len (void);
+double babl_trc_from_linear (const Babl *trc, double value);
+double babl_trc_to_linear (const Babl *trc, double value);
+float babl_trc_from_linearf (const Babl *trc, float value);
+float babl_trc_to_linearf (const Babl *trc, float value);
+
+const Babl * babl_trc_new (const char *name,
+ BablTRCType type,
+ double gamma);
+
#endif
if (yb) *yb = space->space.yb;
}
-BablTRC babl_space_get_trc (const Babl *space, double *gamma)
-{
- if (!space)
- return 0;
- if (gamma) *gamma = space->space.gamma;
- return space->space.trc;
-}
-
const Babl *
babl_space (const char *name)
{
double rx, double ry,
double gx, double gy,
double bx, double by,
- double gamma, BablTRC trc)
+ const Babl *trc_red,
+ const Babl *trc_green,
+ const Babl *trc_blue)
{
int i=0;
static BablSpace space;
space.yb = by;
space.xw = wx;
space.yw = wy;
- space.gamma = gamma;
- space.trc = trc;
+ space.trc[0] = trc_red;
+ space.trc[1] = trc_green?trc_green:trc_red;
+ space.trc[2] = trc_blue?trc_blue:trc_red;
for (i = 0; space_db[i].instance.class_type; i++)
{
int offset = ((char*)&space_db[i].xr) - (char*)(&space_db[i]);
- int size = ((char*)&space_db[i].trc) - ((char*)&space_db[i].xr);
+ int size = ((char*)&space_db[i].trc) + sizeof(space_db[i].trc) - ((char*)&space_db[i].xr);
if (memcmp ((char*)(&space_db[i]) + offset, ((char*)&space) + offset, size)==0)
{
if (name)
sprintf (space_db[i].name, "%s", name);
else
- sprintf (space_db[i].name, "space-%.4f,%.4f_%.4f,%.4f_%.4f,%.4f_%.4f,%.4f_%.4f,%i",
- wx,wy,rx,ry,bx,by,gx,gy,gamma,trc);
+ sprintf (space_db[i].name, "space-%.4f,%.4f_%.4f,%.4f_%.4f,%.4f_%.4f,%.4f_%s,%s,%s",
+ wx,wy,rx,ry,bx,by,gx,gy,babl_get_name (space.trc[0]),
+ babl_get_name(space.trc[1]), babl_get_name(space.trc[2]));
/* compute matrixes */
babl_space_compute_matrices (&space_db[i]);
0.6400, 0.3300,
0.3000, 0.6000,
0.1500, 0.0600,
- 1.0, BABL_TRC_LINEAR);
+ babl_trc("linear"), NULL, NULL);
#else
babl_space_new ("sRGB",
0.3127, 0.3290, /* D65 */
0.6400, 0.3300,
0.3000, 0.6000,
0.1500, 0.0600,
- 2.2, BABL_TRC_SRGB);
+ babl_trc("sRGB"), NULL, NULL);
#endif
babl_space_new ("Adobe",
0.6400, 0.3300,
0.2100, 0.7100,
0.1500, 0.0600,
- 2.2, BABL_TRC_GAMMA);
+ babl_trc("2.2"), NULL, NULL);
babl_space_new ("Apple",
0.3127, 0.3290, /* D65 */
0.6250, 0.3400,
0.2800, 0.5950,
0.1550, 0.0700,
- 1.8, BABL_TRC_GAMMA);
+ babl_trc("1.8"), NULL, NULL);
babl_space_new ("Best",
0.34567, 0.3585, /* D50 */
0.7347, 0.2653,
0.2150, 0.7750,
0.1300, 0.0350,
- 2.2, BABL_TRC_GAMMA);
+ babl_trc("2.2"), NULL, NULL);
babl_space_new ("Beta",
0.34567, 0.3585, /* D50 */
0.6888, 0.3112,
0.1986, 0.7551,
0.1265, 0.0352,
- 2.2, BABL_TRC_GAMMA);
+ babl_trc("2.2"), NULL, NULL);
babl_space_new ("ProPhoto",
0.34567, 0.3585, /* D50 */
0.7347, 0.2653,
0.1596, 0.8404,
0.0366, 0.0001,
- 1.8, BABL_TRC_GAMMA);
+ babl_trc("1.8"), NULL, NULL);
babl_space_new ("Bruce",
0.3127, 0.3290, /* D65 */
0.6400, 0.3300,
0.2800, 0.6500,
0.1500, 0.0600,
- 1.8, BABL_TRC_GAMMA);
+ babl_trc("1.8"), NULL, NULL);
babl_space_new ("PAL",
0.3127, 0.3290, /* D65 */
0.6400, 0.3300,
0.2900, 0.6000,
0.1500, 0.0600,
- 2.2, BABL_TRC_GAMMA);
+ babl_trc("2.2"), NULL, NULL);
babl_space_new ("SMPTE-C",
0.3127, 0.3290, /* D65 */
0.6300, 0.3300,
0.3100, 0.5950,
0.1550, 0.0700,
- 2.2, BABL_TRC_GAMMA);
+ babl_trc("2.2"), NULL, NULL);
babl_space_new ("ColorMatch",
0.34567, 0.3585, /* D50 */
0.6300, 0.3400,
0.2950, 0.6050,
0.1500, 0.0750,
- 1.8, BABL_TRC_GAMMA);
+ babl_trc("1.8"), NULL, NULL);
babl_space_new ("Don RGB 4",
0.34567, 0.3585, /* D50 */
0.6960, 0.3000,
0.2150, 0.7650,
0.1300, 0.0350,
- 1.8, BABL_TRC_GAMMA);
+ babl_trc("1.8"), NULL, NULL);
babl_space_new ("WideGamutRGB",
0.34567, 0.3585, /* D50 */
0.7350, 0.2650,
0.1150, 0.8260,
0.1570, 0.0180,
- 2.2, BABL_TRC_GAMMA);
+ babl_trc("2.2"), NULL, NULL);
}
void babl_space_to_xyz (const Babl *space, const double *rgb, double *xyz)
double xb; // blue primary chromaticity
double yb;
- double gamma;// gamma TRC
- BablTRC trc; // flag for treatment of gamma (sRGB(1) vs just pow(0))
+ const Babl *trc[3];
char name[128];
double RGBtoXYZ[9]; /* matrices for conversions */
} BablSpace;
#include <stdio.h>
-static inline double babl_space_from_linear (const Babl *space_, double value)
-{
- BablSpace *space = (void*)space_;
- switch (space->trc)
- {
- case BABL_TRC_LINEAR:
- return value;
- case BABL_TRC_GAMMA:
- return pow (value, 1.0/space->gamma);
- case BABL_TRC_SRGB:
- return babl_linear_to_gamma_2_2 (value);
- }
- return value;
-}
-
-static inline double babl_space_to_linear (const Babl *space_, double value)
-{
- BablSpace *space = (void*)space_;
- switch (space->trc)
- {
- case BABL_TRC_LINEAR:
- return value;
- case BABL_TRC_GAMMA:
- return pow (value, space->gamma);
- case BABL_TRC_SRGB:
- return babl_gamma_2_2_to_linear (value);
- }
- return value;
-}
-
-static inline float babl_space_from_linearf (const Babl *space_, float value)
-{
- BablSpace *space = (void*)space_;
- switch (space->trc)
- {
- case BABL_TRC_LINEAR: return value;
- case BABL_TRC_GAMMA: return powf (value, 1.0f/space->gamma);
- case BABL_TRC_SRGB: return babl_linear_to_gamma_2_2f (value);
- }
- return value;
-}
-
-static inline float babl_space_to_linearf (const Babl *space_, float value)
-{
- BablSpace *space = (void*)space_;
- switch (space->trc)
- {
- case BABL_TRC_LINEAR: return value;
- case BABL_TRC_GAMMA: return powf (value, space->gamma);
- case BABL_TRC_SRGB: return babl_gamma_2_2_to_linearf (value);
- }
- return value;
-}
#define m(matr, j, i) matr[j*3+i]
--- /dev/null
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2017 Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#define MAX_TRCS 100
+
+#include "config.h"
+#include "babl-internal.h"
+#include "base/util.h"
+
+static BablTRC trc_db[MAX_TRCS];
+
+const Babl *
+babl_trc (const char *name)
+{
+ int i;
+ for (i = 0; trc_db[i].instance.class_type; i++)
+ if (!strcmp (trc_db[i].instance.name, name))
+ {
+ return (Babl*)&trc_db[i];
+ }
+ babl_log("failed to find trc '%s'\n", name);
+ return NULL;
+}
+
+const Babl *
+babl_trc_new (const char *name,
+ BablTRCType type,
+ double gamma)
+{
+ int i=0;
+ static BablTRC trc;
+ trc.instance.class_type = BABL_TRC;
+ trc.instance.id = 0;
+ trc.type = type;
+ trc.gamma = gamma;
+
+ for (i = 0; trc_db[i].instance.class_type; i++)
+ {
+ int offset = ((char*)&trc_db[i].type) - (char*)(&trc_db[i]);
+ int size = ((char*)&trc_db[i].gamma + sizeof(double)) - ((char*)&trc_db[i].type);
+
+ if (memcmp ((char*)(&trc_db[i]) + offset, ((char*)&trc) + offset, size)==0)
+ {
+ return (void*)&trc_db[i];
+ }
+ }
+ if (i >= MAX_TRCS-1)
+ {
+ babl_log ("too many BablTRCs");
+ return NULL;
+ }
+ trc_db[i]=trc;
+ trc_db[i].instance.name = trc_db[i].name;
+ if (name)
+ sprintf (trc_db[i].name, "%s", name);
+ else
+ sprintf (trc_db[i].name, "trc-%i-%f", type, gamma);
+
+ return (Babl*)&trc_db[i];
+}
+
+void
+babl_trc_class_for_each (BablEachFunction each_fun,
+ void *user_data)
+{
+ int i=0;
+ for (i = 0; trc_db[i].instance.class_type; i++)
+ if (each_fun (BABL (&trc_db[i]), user_data))
+ return;
+}
+
+const Babl *
+babl_trc_gamma (double gamma)
+{
+ char name[32];
+ int i;
+ sprintf (name, "%.6f", gamma);
+ for (i = 0; name[i]; i++)
+ if (name[i] == ',') name[i] = '.';
+ while (name[strlen(name)-1]=='0')
+ name[strlen(name)-1]='\0';
+ return babl_trc_new (name, BABL_TRC_GAMMA, gamma);
+}
+
+void
+babl_trc_class_init (void)
+{
+ /* we register sRGB first so that lookups for it is fastest */
+ babl_trc_new ("sRGB", BABL_TRC_SRGB, 2.2);
+ babl_trc_gamma (2.2);
+ babl_trc_gamma (1.8);
+ babl_trc_gamma (1.0);
+ babl_trc_new ("linear", BABL_TRC_LINEAR, 1.0);
+}
+
+double babl_trc_from_linear (const Babl *trc_, double value)
+{
+ return _babl_trc_from_linear (trc_, value);
+}
+
+double babl_trc_to_linear (const Babl *trc_, double value)
+{
+ return _babl_trc_to_linear (trc_, value);
+}
+
+float babl_trc_from_linearf (const Babl *trc_, float value)
+{
+ return _babl_trc_from_linearf (trc_, value);
+}
+
+float babl_trc_to_linearf (const Babl *trc_, float value)
+{
+ return _babl_trc_to_linearf (trc_, value);
+}
+
--- /dev/null
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2017, Øyvind Kolås and others.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BABL_TRC_H
+#define _BABL_TRC_H
+
+#include <math.h>
+#include <string.h>
+#include "base/util.h"
+
+BABL_CLASS_DECLARE (trc);
+
+typedef enum {BABL_TRC_LINEAR,
+ BABL_TRC_GAMMA,
+ BABL_TRC_SRGB} BablTRCType;
+
+typedef struct
+{
+ BablInstance instance;
+ BablTRCType type;
+ double gamma;
+ char name[128];
+
+} BablTRC;
+
+static inline double _babl_trc_from_linear (const Babl *trc_, double value)
+{
+ BablTRC *trc = (void*)trc_;
+ switch (trc->type)
+ {
+ case BABL_TRC_LINEAR:
+ return value;
+ case BABL_TRC_GAMMA:
+ return pow (value, 1.0/trc->gamma);
+ case BABL_TRC_SRGB:
+ return babl_linear_to_gamma_2_2 (value);
+ }
+ return value;
+}
+
+static inline double _babl_trc_to_linear (const Babl *trc_, double value)
+{
+ BablTRC *trc = (void*)trc_;
+ switch (trc->type)
+ {
+ case BABL_TRC_LINEAR:
+ return value;
+ case BABL_TRC_GAMMA:
+ return pow (value, trc->gamma);
+ case BABL_TRC_SRGB:
+ return babl_gamma_2_2_to_linear (value);
+ }
+ return value;
+}
+
+static inline float _babl_trc_from_linearf (const Babl *trc_, float value)
+{
+ BablTRC *trc = (void*)trc_;
+ switch (trc->type)
+ {
+ case BABL_TRC_LINEAR: return value;
+ case BABL_TRC_GAMMA: return powf (value, 1.0f/trc->gamma);
+ case BABL_TRC_SRGB: return babl_linear_to_gamma_2_2f (value);
+ }
+ return value;
+}
+
+static inline float _babl_trc_to_linearf (const Babl *trc_, float value)
+{
+ BablTRC *trc = (void*)trc_;
+ switch (trc->type)
+ {
+ case BABL_TRC_LINEAR: return value;
+ case BABL_TRC_GAMMA: return powf (value, trc->gamma);
+ case BABL_TRC_SRGB: return babl_gamma_2_2_to_linearf (value);
+ }
+ return value;
+}
+
+void
+babl_trc_class_init (void);
+
+#endif
char * dir_list;
babl_internal_init ();
- babl_space_class_init ();
babl_sampling_class_init ();
babl_type_db ();
+ babl_trc_class_init ();
+ babl_space_class_init ();
babl_component_db ();
babl_model_db ();
babl_format_db ();
*/
const Babl * babl_format_with_space (const char *name, const Babl *space);
-typedef enum {
- BABL_TRC_LINEAR,
- BABL_TRC_GAMMA,
- BABL_TRC_SRGB
-} BablTRC;
+/**
+ * babl_trc:
+ *
+ * Look up a TRC by name, "sRGB" "1.0" "linear" and "2.2" are recognized
+ * strings in a stock babl configuration.
+ */
+const Babl * babl_trc (const char *name);
+
+/**
+ * babl_trc_gamma:
+ *
+ * Creates a Babl TRC for a specific gamma value.
+ */
+const Babl * babl_trc_gamma (double gamma);
+
+/**
+ * babl_trc_from_linear:
+ *
+ * Makes linear data non-linear according to the trc.
+ */
+double babl_trc_from_linear (const Babl *trc, double value);
+
+/**
+ * babl_trc_from_linear:
+ *
+ * Makes non-linear data with the TRC linear data.
+ */
+double babl_trc_to_linear (const Babl *trc, double value);
+
+/**
+ * babl_trc_from_linearf:
+ *
+ * Makes linear data non-linear according to the trc, single precision float,
+ * a little bit faster than the double version.
+ */
+float babl_trc_from_linearf (const Babl *trc, float value);
+
+/**
+ * babl_trc_from_linearf:
+ *
+ * Makes non-linear data with the TRC linear data, single precision float
+ * alittle bit faster than the double version.
+ */
+float babl_trc_to_linearf (const Babl *trc, float value);
/**
* babl_space:
* working space referred to by name. Babl knows of:
* sRGB, Adobe, Apple and ProPhoto
*/
-const Babl * babl_space (const char *name);
+const Babl * babl_space (const char *name);
/**
* babl_space_new:
*
* Creates a new RGB matrix color space definition with the specified
* white point wx, wy, primary chromaticities rx,ry,gx,gy,bx,by and
- * TRC to be used. After registering a new babl-space it can be used
- * with babl_space().
+ * TRCs to be used. After registering a new babl-space it can be used
+ * with babl_space() passing its name;
*/
const Babl * babl_space_new (const char *name,
double wx, double wy,
double rx, double ry,
double gx, double gy,
double bx, double by,
- double gamma, BablTRC trc);
+ const Babl *trc_red,
+ const Babl *trc_green,
+ const Babl *trc_blue);
+
void babl_space_to_xyz (const Babl *space, const double *rgb, double *xyz);
void babl_space_from_xyz (const Babl *space, const double *xyz, double *rgb);
*/
const Babl * babl_format_get_space (const Babl *format);
-/*
- * babl_space_get_trc:
- *
- * Returns the type of transfer response curve used for ' annotated components
- * for this space. BABL_TRC_LINEAR means no mapping, BABL_TRC_GAMMA means use
- * the gamma double value and BABL_TRC_SRGB means use the sRGB gamma
- * function.
- *
- * If a pointer to return double is not provided but is NULL, then the trc type
- * is still returned.
- */
-BablTRC babl_space_get_trc (const Babl *space, double *gamma);
-
/**
* babl_space_get_chromaticities:
*
long n)
{
const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl *trc = space->space.trc[0];
BABL_PLANAR_SANITY
while (n--)
{
luminance = red * RGB_LUMINANCE_RED + // XXX: should be taken from BablSpace
green * RGB_LUMINANCE_GREEN +
blue * RGB_LUMINANCE_BLUE;
- *(double *) dst[0] = babl_space_from_linear (space, luminance);
+ *(double *) dst[0] = _babl_trc_from_linear (trc, luminance);
if (dst_bands == 2)
*(double *) dst[1] = alpha;
long n)
{
const Babl *space = babl_conversion_get_source_space (conversion);
+ const Babl *trc = space->space.trc[0];
+
BABL_PLANAR_SANITY
while (n--)
{
double red, green, blue;
double alpha;
- luminance = babl_space_to_linear (space, *(double *) src[0]);
+ luminance = _babl_trc_to_linear (trc, *(double *) src[0]);
red = luminance;
green = luminance;
blue = luminance;
long n)
{
const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl *trc = space->space.trc[0];
while (n--)
{
luminance = red * RGB_LUMINANCE_RED +
green * RGB_LUMINANCE_GREEN +
blue * RGB_LUMINANCE_BLUE;
- luma = babl_space_from_linear (space, luminance);
+ luma = _babl_trc_from_linear (trc, luminance);
((double *) dst)[0] = luma * alpha;
((double *) dst)[1] = alpha;
long n)
{
const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl *trc = space->space.trc[0];
while (n--)
{
double luminance;
luma = luma / alpha;
- luminance = babl_space_to_linear (space, luma);
+ luminance = _babl_trc_to_linear (trc, luma);
((double *) dst)[0] = luminance;
((double *) dst)[1] = luminance;
long samples)
{
const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
long n = samples;
{
int band;
for (band = 0; band < 3; band++)
- *(double *) dst[band] = babl_space_from_linear (space, (*(double *) src[band]));
+ *(double *) dst[band] = _babl_trc_from_linear (trc[band], (*(double *) src[band]));
for (; band < dst_bands; band++)
*(double *) dst[band] = *(double *) src[band];
long samples)
{
const Babl *space = babl_conversion_get_source_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
long n = samples;
BABL_PLANAR_SANITY
int band;
for (band = 0; band < 3; band++)
{
- *(double *) dst[band] = babl_space_to_linear (space, (*(double *) src[band]));
+ *(double *) dst[band] = _babl_trc_to_linear (trc[band], (*(double *) src[band]));
}
for (; band < dst_bands; band++)
{
long samples)
{
const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
long n = samples;
while (n--)
{
double alpha = ((double *) src)[3];
- ((double *) dst)[0] = babl_space_from_linear (space, ((double *) src)[0]) * alpha;
- ((double *) dst)[1] = babl_space_from_linear (space, ((double *) src)[1]) * alpha;
- ((double *) dst)[2] = babl_space_from_linear (space, ((double *) src)[2]) * alpha;
+ ((double *) dst)[0] = _babl_trc_from_linear (trc[0], ((double *) src)[0]) * alpha;
+ ((double *) dst)[1] = _babl_trc_from_linear (trc[1], ((double *) src)[1]) * alpha;
+ ((double *) dst)[2] = _babl_trc_from_linear (trc[2], ((double *) src)[2]) * alpha;
((double *) dst)[3] = alpha;
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
long samples)
{
const Babl *space = babl_conversion_get_source_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
long n = samples;
while (n--)
double alpha = ((double *) src)[3];
if (alpha > BABL_ALPHA_THRESHOLD)
{
- ((double *) dst)[0] = babl_space_to_linear (space, ((double *) src)[0] / alpha);
- ((double *) dst)[1] = babl_space_to_linear (space, ((double *) src)[1] / alpha);
- ((double *) dst)[2] = babl_space_to_linear (space, ((double *) src)[2] / alpha);
+ ((double *) dst)[0] = _babl_trc_to_linear (trc[0], ((double *) src)[0] / alpha);
+ ((double *) dst)[1] = _babl_trc_to_linear (trc[1], ((double *) src)[1] / alpha);
+ ((double *) dst)[2] = _babl_trc_to_linear (trc[2], ((double *) src)[2] / alpha);
}
else
{
long samples)
{
const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
long n = samples;
while (n--)
{
double alpha = ((double *) src)[3];
- ((double *) dst)[0] = babl_space_from_linear (space, ((double *) src)[0]);
- ((double *) dst)[1] = babl_space_from_linear (space, ((double *) src)[1]);
- ((double *) dst)[2] = babl_space_from_linear (space, ((double *) src)[2]);
+ ((double *) dst)[0] = _babl_trc_from_linear (trc[0], ((double *) src)[0]);
+ ((double *) dst)[1] = _babl_trc_from_linear (trc[1], ((double *) src)[1]);
+ ((double *) dst)[2] = _babl_trc_from_linear (trc[2], ((double *) src)[2]);
((double *) dst)[3] = alpha;
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
long samples)
{
const Babl *space = babl_conversion_get_source_space (conversion);
+ const Babl **trc = (void*)(space->space.trc);
long n = samples;
while (n--)
{
double alpha = ((double *) src)[3];
- ((double *) dst)[0] = babl_space_to_linear (space, ((double *) src)[0]);
- ((double *) dst)[1] = babl_space_to_linear (space, ((double *) src)[1]);
- ((double *) dst)[2] = babl_space_to_linear (space, ((double *) src)[2]);
+ ((double *) dst)[0] = _babl_trc_to_linear (trc[0], ((double *) src)[0]);
+ ((double *) dst)[1] = _babl_trc_to_linear (trc[1], ((double *) src)[1]);
+ ((double *) dst)[2] = _babl_trc_to_linear (trc[2], ((double *) src)[2]);
((double *) dst)[3] = alpha;
src += 4 * sizeof (double);
static inline float
init_newtonf (float x, float exponent, float c0, float c1, float c2)
{
- int iexp;
+ int iexp = 0;
float y = babl_frexpf(x, &iexp);
y = 2*y+(iexp-2);
c1 *= M_LN2*exponent;